package com.eriloan.easyPage.plugins.templates.velocity.directive;

import java.io.IOException;
import java.io.Writer;

import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.parser.node.Node;

import com.eriloan.easyPage.util.EasyPageContext;

/**
 * 
 * <p>Copyright: All Rights Reserved</p>
 * <p>Company: 北京荣之联科技股份有限公司 http://www.ronglian.com</p>
 * <p>Description: 自定义Directive抽象基类 </p>
 * <p>Author:Eric Shi/史丙利</p>
 */
public abstract class EasyPageAbstractDirective extends Directive{

	/**
	 * 
	 * <p>Description:覆盖render方法</p>
	 * <p>Author:Eric Shi/史丙利</p>
	 * 
	 * @Title: render
	 * @param internalContext
	 * @param writer
	 * @param node
	 * @return
	 * @throws IOException
	 * @throws ResourceNotFoundException
	 * @throws ParseErrorException
	 * @throws MethodInvocationException
	 * @see org.apache.velocity.runtime.directive.Directive#render(org.apache.velocity.context.InternalContextAdapter,
	 *      java.io.Writer, org.apache.velocity.runtime.parser.node.Node)
	 */
	@Override
	public boolean render(InternalContextAdapter internalContext,Writer writer,Node node) throws IOException,ResourceNotFoundException,ParseErrorException,MethodInvocationException{
		EasyPageContext epc = new EasyPageContext();
		return doRender(internalContext,epc,writer,node);
	}

	/**
	 * 
	 * <br/>Description:自定义render方法
	 * <p>Author:Eric Shi/史丙利</p>
	 * 
	 * @param internalContext
	 * @param context
	 * @param writer
	 * @param node
	 * @return
	 * @throws IOException
	 * @throws ResourceNotFoundException
	 * @throws ParseErrorException
	 * @throws MethodInvocationException
	 */
	public abstract boolean doRender(InternalContextAdapter internalContext,EasyPageContext context,Writer writer,Node node) throws IOException,ResourceNotFoundException,ParseErrorException,MethodInvocationException;
}